<?php
/**
 * 后台订单管理控制器
 */
 class OrderController extends IsLoginController{
 	
	 public function index(){
	 	//查询分配订单信息
	 	$order = M('user_order')->JOIN("__user_order__ o join __order_list__ list join __goods__ g on o.oid = list.order_id AND list.goods_gid = g.gid")->group("oid")->all();
		$this->assign('order',$order);
	 	$this->display();
	 }
	 
	 //管理员发货
	 public function Ordersend(){
	 	$order = M('user_order')->JOIN("__user_order__ o join __order_list__ list join __goods__ g on o.oid = list.order_id AND list.goods_gid = g.gid")->where("order_status=1")->group("oid")->all();
		$this->assign('order',$order);
	 	$this->display();
	 }
	 
	 //异步请求 处理发货
	 public function sendGoods(){
	 	if(IS_AJAX){
			$oid = Q('post.oid');
			//改变状态3为确认收货
			$data['order_status'] = 2;
			//写入数据库
			M('user_order')->where("oid ='{$oid}'")->update($data);
			$this->ajax('1');
	 	}
	 }

 }